<?php /*a:7:{s:69:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\user\profile.html";i:1660015756;s:63:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\layout.html";i:1659685605;s:68:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\common\meta.html";i:1659584544;s:70:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\common\script.html";i:1659584105;s:70:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\common\header.html";i:1660015203;s:68:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\common\menu.html";i:1660191692;s:70:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\common\footer.html";i:1659584054;}*/ ?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
<title>ask论坛</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="keywords" content="fly,layui,前端社区">
<meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
<link rel="stylesheet" href="/static/home/res/layui/css/layui.css">
<link rel="stylesheet" href="/static/home/res/css/global.css">


    <!-- 引入js -->
    <script src="/static/home/res/layui/layui.js"></script>
<script>
    layui.cache.page = '';
    layui.cache.user = {
        username: '游客'
        , uid: -1
        , avatar: '/static/home/res/images/avatar/00.jpg'
        , experience: 83
        , sex: '男'
    };
    layui.config({
        version: "3.0.0"
        , base: '/static/home/res/mods/' //这里实际使用时，建议改成绝对路径
    }).extend({
        fly: 'index'
    }).use('fly');
</script>
</head>

<body>
    <!-- 公共头部 -->
    <div class="fly-header layui-bg-black">
    <div class="layui-container">
        <a class="fly-logo" href="<?php echo url('/'); ?>">
            <img src="/static/home/res/images/logo.png" alt="layui">
        </a>

        <?php if((app('request')->action() !== 'login' && app('request')->action() !== 'register')): ?>
        <ul class="layui-nav fly-nav-user">

            <!-- 未登入的状态 -->
            <?php if((!app('request')->cookie('LoginUser'))): ?>
            <li class="layui-nav-item">
                <a class="iconfont icon-touxiang layui-hide-xs" href="user/login.html"></a>
            </li>
            <li class="layui-nav-item">
                <a href="<?php echo url('/home/index/login'); ?>">登入</a>
            </li>
            <li class="layui-nav-item">
                <a href="<?php echo url('/home/index/register'); ?>">注册</a>
            </li>
            <?php else: ?>

            <!-- 登入后的状态 -->

            <li class="layui-nav-item">
                <a class="fly-nav-avatar" href="javascript:;">
                    <cite class="layui-hide-xs"><?php echo htmlentities($LoginUser['nickname']); ?></cite>
                    <?php if(($LoginUser['auth'] == 1)): ?>
                    <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：<?php echo htmlentities($LoginUser['nickname']); ?>"></i>
                    <?php endif; ?>
                    <i class="layui-badge fly-badge-vip layui-hide-xs">VIP <?php echo htmlentities($LoginUser['vip']); ?></i>
                    <img
                        src="<?php echo !empty($LoginUser['avatar']) ? '/' . $LoginUser['avatar']  :  '/static/home/res/images/avatar/default.png'; ?>">
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="<?php echo url('/home/user/profile'); ?>"><i class="layui-icon">&#xe620;</i>基本资料</a></dd>
                    <dd><a href="user/message.html"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a></dd>
                    <dd><a href="/home/user"><i class="layui-icon"
                                style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a></dd>
                    <hr style="margin: 5px 0;">
                    <dd><a href="<?php echo url('home/index/logout'); ?>" style="text-align: center;">退出</a></dd>
                </dl>
            </li>
            <?php endif; ?>
        </ul>
        <?php endif; ?>
    </div>
</div>

    <!-- 输出子内容 -->
    <style>
    .layui-form-item .layui-input-inline {
        width: auto;
    }

    .avatar-add img {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 220px;
        height: 168px;
        margin: -50px 0 0 -111px;
        border-radius: 0%;
    }
</style>
<div class="layui-container fly-marginTop fly-user-main">

    <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="user">
    <li class="layui-nav-item">
        <a href="<?php echo url('/home/user/index'); ?>">
            <i class="layui-icon">&#xe609;</i>
            我的主页
        </a>
    </li>
    <!-- <li class="layui-nav-item">
        <a href="index.html">
            <i class="layui-icon">&#xe612;</i>
            用户中心
        </a>
    </li> -->
    <li class="layui-nav-item <?php echo $action=='profile' ? 'layui-this' : ''; ?>">
        <a href="<?php echo url('/home/user/profile'); ?>">
            <i class="layui-icon">&#xe620;</i>
            基本资料
        </a>
    </li>
    <li class="layui-nav-item <?php echo $action=='mypost' ? 'layui-this' : ''; ?>">
        <a href="/home/user/mypost">
            <i class="layui-icon">&#xe611;</i>
            我的发表
        </a>
    </li>
</ul>


    <div class="fly-panel fly-panel-user" pad20>
        <div class="layui-tab layui-tab-brief" lay-filter="user">
            <ul class="layui-tab-title" id="LAY_mine">
                <li class="layui-this" lay-id="info">我的资料</li>
                <li lay-id="avatar">头像</li>
                <li lay-id="pass">密码</li>
                <li lay-id="bind">修改背景</li>
            </ul>
            <div class="layui-tab-content" style="padding: 20px 0;">
                <div class="layui-form layui-form-pane layui-tab-item layui-show">
                    <form method="post">
                        <div class="layui-form-item">
                            <label for="L_email" class="layui-form-label">邮箱</label>
                            <div class="layui-input-inline">
                                <input type="text" id="L_email" name="email" value="<?php echo htmlentities($LoginUser['email']); ?>" disabled
                                    lay-verify="email" autocomplete="off" value="" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">
                                <?php if($LoginUser['auth'] != 1): ?>
                                您的邮箱未激活，请点击<a id="auth"
                                    style="font-size: 12px; color: #4f99cf;cursor: pointer;">验证邮箱</a>。
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_username" class="layui-form-label">昵称</label>
                            <div class="layui-input-inline">
                                <input type="text" id="L_username" name="nickname" value="<?php echo htmlentities($LoginUser['nickname']); ?>"
                                    required lay-verify="required" autocomplete="off" value="" class="layui-input">
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="radio" name="sex" value="0" title="保密" <?php echo $LoginUser['sex']==0 ? 'checked'  :  ''; ?>>
                                    <input type="radio" name="sex" value="1" title="男" <?php echo $LoginUser['sex']==1 ? 'checked'
                                         :  ''; ?>>
                                    <input type="radio" name="sex" value="2" title="女" <?php echo $LoginUser['sex']==2 ? 'checked'
                                         :  ''; ?>>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label for="province" class="layui-form-label">省</label>
                            <div class="layui-input-inline" style="width: 180px;">
                                <select name="province" id="province" lay-filter="province">
                                    <option value="0">请选择</option>
                                    <?php foreach($province as $item): ?>
                                    <option value="<?php echo htmlentities($item['code']); ?>" <?php echo $LoginUser['province']==$item['code'] ? 'selected'
                                         :  ''; ?>><?php echo htmlentities($item['name']); ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>

                            <label for="city" class="layui-form-label">市</label>
                            <div class="layui-input-inline" style="width: 180px;">
                                <select name="city" id="city" lay-filter="city">
                                    <option value="0">请选择</option>
                                    <?php foreach($city as $item): ?>
                                    <option value="<?php echo htmlentities($item['code']); ?>" <?php echo $LoginUser['city']==$item['code'] ? 'selected'  :  ''; ?>><?php echo htmlentities($item['name']); ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>

                            <label for="district" class="layui-form-label">区</label>
                            <div class="layui-input-inline" style="width: 180px;">
                                <select name="district" id="district">
                                    <option value="0">请选择</option>
                                    <?php foreach($district as $item): ?>
                                    <option value="<?php echo htmlentities($item['code']); ?>" <?php echo $LoginUser['district']==$item['code'] ? 'selected'
                                         :  ''; ?>><?php echo htmlentities($item['name']); ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label for="L_content" class="layui-form-label">签名</label>
                            <div class="layui-input-block">
                                <textarea placeholder="随便写些什么刷下存在感" id="L_content" name="content" autocomplete="off"
                                    class="layui-textarea" style="height: 80px;"><?php echo htmlentities($LoginUser['content']); ?></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn" key="set-mine" lay-submit>确认修改</button>
                        </div>
                    </form>
                </div>

                <div class="layui-form layui-form-pane layui-tab-item">
                    <div class="layui-form-item">
                        <form method="post" enctype="multipart/form-data">
                            <input type="hidden" name="action" value="avatar">
                            <div class="avatar-add">
                                <p>建议尺寸168*168，支持jpg、png、gif，最大不能超过50KB</p>
                                <button type="button" class="layui-btn upload-img" onclick="avatar.click()">
                                    <i class="layui-icon">&#xe67c;</i>上传头像
                                </button>
                                <input type="file" name="avatar" id="avatar" hidden>
                                <img src="<?php echo !empty($LoginUser['avatar']) ? '/' . $LoginUser['avatar']  :  '/static/home/res/images/upload.png'; ?>"
                                    id="img">
                                <span class="loading"></span>
                            </div>

                            <button class="layui-btn">上传</button>

                        </form>
                    </div>
                </div>

                <div class="layui-form layui-form-pane layui-tab-item">
                    <form method="post">
                        <input type="hidden" name="action" value="password" />
                        <div class="layui-form-item">
                            <label for="L_nowpass" class="layui-form-label">当前密码</label>
                            <div class="layui-input-inline">
                                <input type="password" id="L_nowpass" name="nowpass" required lay-verify="required"
                                    autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_pass" class="layui-form-label">新密码</label>
                            <div class="layui-input-inline">
                                <input type="password" id="L_pass" name="pass" required lay-verify="required"
                                    autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">6到16个字符</div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_repass" class="layui-form-label">确认密码</label>
                            <div class="layui-input-inline">
                                <input type="password" id="L_repass" name="repass" required lay-verify="required"
                                    autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn" key="set-mine" lay-submit>确认修改</button>
                        </div>
                    </form>
                </div>

                <!-- <div class="layui-form layui-form-pane layui-tab-item">
                    <ul class="app-bind">
                        <li class="fly-msg app-havebind">
                            <i class="iconfont icon-qq"></i>
                            <span>已成功绑定，您可以使用QQ帐号直接登录Fly社区，当然，您也可以</span>
                            <a href="javascript:;" class="acc-unbind" type="qq_id">解除绑定</a>

                            <!-- <a href="" onclick="layer.msg('正在绑定微博QQ', {icon:16, shade: 0.1, time:0})" class="acc-bind" type="qq_id">立即绑定</a>
                  <span>，即可使用QQ帐号登录Fly社区</span> -->
                <!-- </li>
                        <li class="fly-msg">
                            <i class="iconfont icon-weibo"></i> -->
                <!-- <span>已成功绑定，您可以使用微博直接登录Fly社区，当然，您也可以</span>
                  <a href="javascript:;" class="acc-unbind" type="weibo_id">解除绑定</a>

                            <a href="" class="acc-weibo" type="weibo_id"
                                onclick="layer.msg('正在绑定微博', {icon:16, shade: 0.1, time:0})">立即绑定</a>
                            <span>，即可使用微博帐号登录Fly社区</span>
                        </li>
                    </ul>
                </div> -->

                <div class="layui-form layui-form-pane layui-tab-item">
                    <div class="layui-form-item">
                        <form method="post" enctype="multipart/form-data">
                            <input type="hidden" name="action" value="cover">
                            <div class="avatar-add">
                                <p>建议尺寸168*168，支持jpg、png、gif，最大不能超过50KB</p>
                                <button type="button" class="layui-btn upload-img" onclick="cover.click()">
                                    <i class="layui-icon">&#xe67c;</i>上传背景图
                                </button>
                                <input type="file" name="cover" id="cover" hidden>
                                <img src="<?php echo !empty($LoginUser['cover']) ? htmlentities($LoginUser['cover']) :  '/static/home/res/images/upload.png'; ?>"
                                    id="cov-img">
                                <span class="loading"></span>
                            </div>

                            <button class="layui-btn">上传</button>

                        </form>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
</div>

</div>

<script>
    // 引入layui的组件
    layui.use(['layer', 'form'], function () {

        var $ = layui.jquery,
            layer = layui.layer,
            form = layui.form

        // 选择省份 form.on => layui事件 select => change
        form.on('select(province)', function (data) {
            var code = data.value

            $.ajax({
                type: "post",
                url: `<?php echo url('/home/user/area'); ?>`,
                data: {
                    code
                },
                dataType: "json",
                success: function (res) {
                    if (res.code === 1) {
                        var option = ''

                        res.data.forEach(item => {
                            option += `<option value="${item.code}">${item.name}</option>`
                        })

                        $('#city').html(option)

                        // 调用函数查询某个省份第一个城市的所有的区
                        GetRegion(res.data[0].code, '#district')
                        // 渲染 select 选择框
                        form.render('select')
                    }


                }
            });
        })

        // 选择市
        form.on('select(city)', function (data) {
            var code = data.value

            GetRegion(code, '#district')
        })

        $("#avatar").change(function () {
            var file = $(this)[0].files[0] ? $(this)[0].files[0] : {}

            var url = GetObjectURL(file)

            $('#img').attr('src', url)
        })

        // 图片预览函数
        function GetObjectURL(file) {
            // createObjectURL  给一个文件对象 可以提取出一个url本地地址出来
            var url = null;

            //判断是否为IE浏览器还是google还是其他浏览器
            if (window.createObjectURL != undefined) {
                url = window.createObjectURL(file)
            } else if (window.URL != undefined) {
                url = window.URL.createObjectURL(file)
            } else if (window.webkitURL != undefined) {
                url = window.webkitURL.createObjectURL(file)
            }

            return url
        }

        function GetRegion(code, element) {
            $.ajax({
                type: "post",
                url: `<?php echo url('/home/user/area'); ?>`,
                data: {
                    code
                },
                dataType: "json",
                success: function (res) {
                    if (res.code === 1) {
                        var option = ''

                        res.data.forEach(item => {
                            option += `<option value="${item.code}">${item.name}</option>`
                        })

                        $(element).html(option)

                        form.render('select')
                    }


                }
            });
        }

        $('#auth').click(function () {
            var email = $('#L_email').val();

            $.ajax({
                type: "post",
                url: `<?php echo url('/home/user/email'); ?>`,
                data: {
                    email
                },
                dataType: "json",
                success: function (res) {

                    if (res.code === 1) {
                        layer.msg(res.msg)
                    } else {
                        layer.msg(res.msg)
                    }
                }
            });
        })

        $("#cover").change(function () {
            var file = $(this)[0].files[0] ? $(this)[0].files[0] : {}

            var url = GetObjectURL(file)

            $('#cov-img').attr('src', url)
        })
    })
</script>

    <!-- 底部 -->
    <div class="fly-footer">
    <p>2017 &copy; <a href="http://www.layui.com/" target="_blank">Fly技术社区</a></p>
</div>

</body>

</html>